import com.sun.java.swing.plaf.windows.WindowsTextAreaUI;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.*;

public class OpenSource {
    public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        // String s = "qwe";   // String 源码
        // stringBufferSource();    // StringBuffer 源码

        // hashMapResource();   // HashMap源码

        arrayListSource();  // arryList源码

        AtomicInteger atomicInteger = new AtomicInteger();
        atomicInteger.getAndIncrement();

        Thread myThread = new Thread(() -> {
            System.out.println();
        }, "demo01");

        Hashtable hashtable = new Hashtable();
        ReentrantLock lock = new ReentrantLock();
//        ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
//        lock.lock();
//        ArrayBlockingQueue
        Condition condition1 = lock.newCondition();

        Test test = (Test) Class.forName("Test").newInstance();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(3);
        list.add(2);
        list.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });
        System.out.println(list.toString());
    }

    /**
     * treeSetSource
     */
    public static void treeSetSource(){
        Set<Integer> set = new TreeSet<>();
        set.add(1);
    }

    /**
     * linkedHashSetSource
     */
    public static void linkedHashSetSource(){
        Set<Integer> set = new LinkedHashSet<>();
        set.add(1);
    }

    /**
     * hashSetSource
     */
    public static void hashSetSource() {
        Set<Integer> set = new HashSet<>();
        set.add(1);
        set.add(2);
    }

    /**
     * arrayDequeueSource
     */
    public static void arrayDequeueSource(){
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(1);
        deque.add(2);
    }

    /**
     * priorityQueueSource queue
     */
    public static void priorityQueueSource(){
        Queue<Integer> queue = new PriorityQueue<>();
        queue.add(1);
        queue.add(2);
    }
    /**
     * vector
     */
    public static void vectorSource(){
        Vector<Integer> vector = new Vector<>();
        vector.add(1);
        vector.add(2);
    }

    /**
     * LinkedListSource
     */
    public static void LinkedListSource() {
        List<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
    }

    /**
     * 1
     * arrayListSource
     */
    public static void arrayListSource() {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
    }

    /**
     * 1
     * collection
     */
    public static void collectionOrSSource(){
        List<Integer> list = new LinkedList<>();

        Iterator iterator = list.iterator();

    }


    /**
     * 1
     * stringBuilderSource
     */
    public static void stringBuilderSource() {
        StringBuilder stringBuilder = new StringBuilder("abc");
    }

    /**
     * 1
     * stringBufferSource
     */
    public static void stringBufferSource() {
        StringBuffer stringBuffer = new StringBuffer("abc");
        StringBuffer stringBuffer2 = new StringBuffer("deadefdefdefdefdefdefdef");
        stringBuffer.append(stringBuffer2);
//        System.out.println(stringBuffer.length());
//        System.out.println(stringBuffer.capacity());
        System.out.println(stringBuffer2.codePointAt(2));

    }

    /**
     *  1
     * hashmap
     */
    public static void hashMapResource() {
        HashMap hashMap = new HashMap();
        for(int i=0; i<16; i++) {
            System.out.println("PUT第"+i+"个数据");
            String ss = "test"+i;
            hashMap.put("ss", ss);
        }
    }

    /**
     * 1
     * hashTableSource
     */
    public static void hashTableSource(){
        Map<Integer, Integer> map = new Hashtable<>();
        map.put(1, 1);
    }

    /**
     * treeMapSource
     */
    public static void treeMapSource(){
        Map<Integer, Integer> map = new TreeMap<>();
        map.put(1, 1);
    }
}
